<template>
  <el-form
    ref="PhoneRuleFormRef"
    :model="PhoneRuleForm"
    :rules="PhoneRules"
    class="demo-PhoneRuleForm"
    status-icon
  >
    <el-form-item label="手机号" prop="phone">
      <el-input v-model="PhoneRuleForm.phone" />
    </el-form-item>
    <el-form-item
      class="demo-PhoneRuleForm-form-item"
      label="验证码"
      prop="code"
    >
      <el-input
        class="demo-PhoneRuleForm-form-item-input"
        v-model="PhoneRuleForm.code"
      />
      <el-button type="primary">获取验证码</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue'
import type { FormInstance, FormRules } from 'element-plus'
// ref实例
const PhoneRuleFormRef = ref<FormInstance>()
// 双向绑定的数据
const PhoneRuleForm = reactive({
  phone: '',
  code: ''
})
// 规则
const PhoneRules = reactive<FormRules>({
  phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
  code: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
})
</script>

<style lang="scss" scoped>
.demo-PhoneRuleForm {
  &-form-item {
    display: flex;

    align-items: center;
    &-input {
      width: 100px;
    }
  }
}

:deep(.el-form-item__content) {
  justify-content: space-between;
}
</style>
